In [1]:
pip install matplotlib
Requirement already satisfied: matplotlib in c:\users\abhio\anaconda3\lib\site-packages (3.7.2)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\abhio\anaconda3\lib\site-packages (from matplotlib) (1.0.5)
Requirement already satisfied: cycler>=0.10 in c:\users\abhio\anaconda3\lib\site-packages (from matplotlib) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\abhio\anaconda3\lib\site-packages (from matplotlib) (4.25.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\abhio\anaconda3\lib\site-packages (from matplotlib) (1.4.4)
Requirement already satisfied: numpy>=1.20 in c:\users\abhio\anaconda3\lib\site-packages (from matplotlib) (1.24.3)
Requirement already satisfied: packaging>=20.0 in c:\users\abhio\anaconda3\lib\site-packages (from matplotlib) (23.1)
Requirement already satisfied: pillow>=6.2.0 in c:\users\abhio\anaconda3\lib\site-packages (from matplotlib) (10.0.1)
Requirement already satisfied: pyparsing<3.1,>=2.3.1 in c:\users\abhio\anaconda3\lib\site-packages (from matplotlib) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\abhio\anaconda3\lib\site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: six>=1.5 in c:\users\abhio\anaconda3\lib\site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)
Note: you may need to restart the kernel to use updated packages.
In [2]:
import matplotlib 
matplotlib.__version__
Out[2]:
'3.7.2'
In [3]:
import matplotlib.pyplot as plt

Bar Plot¶

In [ ]:
import matplotlib.pyplot as plt

x = []
y = []

plt.bar(x,y)
plt.show()
In [4]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]

plt.bar(x,y)
plt.show()
In [2]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]


plt.xlabel("language")
plt.ylabel("No")
plt.title("wscube")

plt.bar(x,y)
plt.show()
In [6]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]

plt.xlabel("language",fontsize = 55)
plt.ylabel("No",fontsize = 55)
plt.title("wscube",fontsize = 55)

c = ["y","b","m","g"]

plt.bar(x,y,width = 0.4,color = 'y')
plt.legend()
plt.show()
No artists with labels found to put in legend.  Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
In [13]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]

plt.xlabel("language",fontsize = 25)
plt.ylabel("No",fontsize = 25)
plt.title("wscube",fontsize = 25)

c = ["y","b","m","g"]

plt.bar(x,y,width = 0.4,color = c)
plt.show()
In [10]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]

plt.xlabel("language",fontsize = 55)
plt.ylabel("No",fontsize = 55)
plt.title("wscube",fontsize = 55)

c = ["y","b","m","g"]

plt.bar(x,y,width = 0.4,color = c,align="edge")#edge par line
plt.show()
No artists with labels found to put in legend.  Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
In [12]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]

plt.xlabel("language",fontsize = 55)
plt.ylabel("No",fontsize = 55)
plt.title("wscube",fontsize = 55)

c = ["y","b","m","g"]

plt.bar(x,y,width = 0.4,color = c,align="center")#center par line
plt.show()
No artists with labels found to put in legend.  Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
In [14]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]

plt.xlabel("language",fontsize = 55)
plt.ylabel("No",fontsize = 55)
plt.title("wscube",fontsize = 55)

c = ["y","b","m","g"]

plt.bar(x,y,width = 0.4,color = c,edgecolor='r')
plt.show()
In [17]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]

plt.xlabel("language",fontsize = 25)
plt.ylabel("No",fontsize = 25)
plt.title("wscube",fontsize = 25)

c = ["y","b","m","g"]

plt.bar(x,y,width = 0.4,color = c,edgecolor = 'r',linewidth = 5)#linewidth means outer of border line width
plt.show()#edgecolor is edge color line
In [19]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]

plt.xlabel("language",fontsize = 35)
plt.ylabel("No",fontsize = 35)
plt.title("wscube",fontsize = 55)

c = ["y","b","m","g"]

plt.bar(x,y,width = 0.4,color = c,edgecolor = 'r',linewidth = 5,linestyle = ":")
plt.show()
In [21]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]

plt.xlabel("language",fontsize = 25)
plt.ylabel("No",fontsize = 25)
plt.title("wscube",fontsize = 55)

c = ["y","b","m","g"]
#alpha value is blare graph
plt.bar(x,y,width = 0.4,color = 'y',linewidth = 5,linestyle = ":",alpha = 0.4)
plt.show()
In [24]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]

plt.xlabel("language",fontsize = 25)
plt.ylabel("No",fontsize = 25)
plt.title("wscube",fontsize = 55)

c = ["y","b","m","g"]

plt.bar(x,y,width = 0.4,color = c,linewidth = 5,linestyle = ":",label = "Popularity")
plt.legend()
plt.show()
In [28]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]
z = [20,30,40,50]

plt.xlabel("language",fontsize = 15)
plt.ylabel("No",fontsize = 15)
plt.title("wscube",fontsize = 15)

c = ["y","b","m","g"]

plt.bar(x,y,width = 0.4,color = 'r',label = "Popularity")
plt.bar(x,z,width = 0.4,color = 'y',label = "Popularity1")
plt.legend()
plt.show()
In [38]:
import matplotlib.pyplot as plt

x = ["python","c","c++","java"]
y = [65,34,87,98]
z = [20,30,40,50]

plt.xlabel("language",fontsize = 15)
plt.ylabel("No",fontsize = 15)
plt.title("wscube",fontsize = 15)

c = ["y","b","m","g"]
width = 0.2
plt.barh(x,y,width,color = 'r',label = "Popularity")
plt.barh(x,z,width,color = 'y',label = "Popularity1")
plt.legend()
plt.show()
In [31]:
import matplotlib.pyplot as plt
import numpy as np

x = ["python","c","c++","java"]
y = [65,34,87,98]
z = [20,30,40,50]
p = np.arange(len(x))#p is change the x value

plt.xlabel("language",fontsize = 15)
plt.ylabel("No",fontsize = 15)
plt.title("wscube",fontsize = 15)

#c = ["y","b","m","g"]
width = 0.2

plt.bar(p,y,width,color = 'r',label = "Popularity")
plt.bar(p,z,width,color = 'y',label = "Popularity1")
plt.legend()
plt.show()
In [33]:
import matplotlib.pyplot as plt
import numpy as np

x = ["python","c","c++","java"]
y = [65,34,87,98]
z = [200,300,400,500]

width = 0.2
p = np.arange(len(x))
p1 = [j+width for j in p]

plt.xlabel("language",fontsize = 15)
plt.ylabel("No",fontsize = 15)
plt.title("wscube",fontsize = 15)

plt.bar(p,y,width,color = 'r',label = "Popularity")
plt.bar(p1,z,width,color = 'g',label = "Popularity1")

plt.legend()
plt.show()
In [34]:
import matplotlib.pyplot as plt
import numpy as np

x = ["python","c","c++","java"]
y = [65,34,87,98]
z = [200,300,400,500]

width = 0.2
p = np.arange(len(x))
p1 = [j+width for j in p]

plt.xlabel("language",fontsize = 15)
plt.ylabel("No",fontsize = 15)
plt.title("wscube",fontsize = 15)

plt.bar(p,y,width,color = 'r',label = "Popularity")
plt.bar(p1,z,width,color = 'g',label = "Popularity1")

plt.xticks(p+width,x)
plt.legend()
plt.show()
In [35]:
import matplotlib.pyplot as plt
import numpy as np

x = ["python","c","c++","java"]
y = [65,34,87,98]
z = [200,300,400,500]

width = 0.2
p = np.arange(len(x))
p1 = [j+width for j in p]

plt.xlabel("language",fontsize = 15)
plt.ylabel("No",fontsize = 15)
plt.title("wscube",fontsize = 15)

plt.bar(p,y,width,color = 'r',label = "Popularity")
plt.bar(p1,z,width,color = 'g',label = "Popularity1")

plt.xticks(p+width/2,x)
plt.legend()
plt.show()
In [32]:
import matplotlib.pyplot as plt
import numpy as np

x = ["python","c","c++","java"]
y = [65,34,87,98]
z = [200,300,400,500]

width = 0.2
p = np.arange(len(x))
p1 = [j+width for j in p]

plt.xlabel("language",fontsize = 15)
plt.ylabel("No",fontsize = 15)
plt.title("wscube",fontsize = 15)

plt.bar(p,y,width,color = 'r',label = "Popularity")
plt.bar(p1,z,width,color = 'g',label = "Popularity1")

plt.xticks(p+width/2,x,rotation = 20)#divide by 2 means languages are mid in both compare popularity
plt.legend()
plt.show()
In [8]:
import matplotlib.pyplot as plt
import numpy as np

x = ["python","c","c++","java"]
y = [65,34,87,98]
z = [200,300,400,500]

width = 0.2
p = np.arange(len(x))
p1 = [j+width for j in p]

plt.xlabel("language",fontsize = 15)
plt.ylabel("No",fontsize = 15)
plt.title("wscube",fontsize = 15)

plt.barh(p,y,width,color = 'r',label = "Popularity")#h is define horizontal graph
plt.barh(p1,z,width,color = 'g',label = "Popularity1")

plt.xticks(p+width/2,x,rotation = 20)
plt.legend()
plt.show()
In [36]:
import matplotlib.pyplot as plt
import numpy as np

x = ["python","c","c++","java"]
y = [65,34,87,98]
z = [200,300,400,500]

width = 0.2
p = np.arange(len(x))
p1 = [j+width for j in p]

plt.xlabel("language",fontsize = 15)
plt.ylabel("No",fontsize = 15)
plt.title("wscube",fontsize = 15)

plt.barh(p,y,width,color = 'r',label = "Popularity")#h is define horizontal graph
plt.bar(p1,z,width,color = 'g',label = "Popularity1")#bar is only use vertical graph

plt.xticks(p+width/2,x,rotation = 20)
plt.legend()
plt.show()

Scatter Plot¶

In [9]:
import matplotlib.pyplot as plt

x = []
y = []

plt.scatter(x,y)
plt.show()
In [10]:
import matplotlib.pyplot as plt
x = [1,2,3,4,5,6,7]
y = [4,5,6,7,8,9,4]

plt.scatter(x,y)
plt.show()
In [40]:
import matplotlib.pyplot as plt
day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no)
plt.show()
In [41]:
import matplotlib.pyplot as plt
day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no,color = 'r')
plt.show()
In [42]:
import matplotlib.pyplot as plt
day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]

colors = ["r","y","g","b","r","g","r"]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no,c = colors)
plt.show()
In [12]:
import matplotlib.pyplot as plt
day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]

colors = ["r","y","g","b","r","g","r"]
sizes = [10,90,80,70,60,50,400]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no,c = colors,s = sizes)
plt.show()
In [13]:
import matplotlib.pyplot as plt
day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]

colors = ["r","y","g","b","r","g","r"]
sizes = [10,90,80,70,60,50,400]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no,c = colors,s = sizes,alpha = 0.5)
plt.show()
In [14]:
import matplotlib.pyplot as plt
day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]

colors = ["r","y","g","b","r","g","r"]
sizes = [10,90,80,70,60,50,400]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no,c = colors,s = sizes,marker = "*")#maker is change the shape
plt.show()
In [46]:
import matplotlib.pyplot as plt
day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]

colors = ["r","y","g","b","r","g","r"]
sizes = [100,99,809,710,609,510,400]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no,c = colors,s = sizes,marker = "*",edgecolor = "m",linewidth = 1)
plt.show()
In [15]:
import matplotlib.pyplot as plt
day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]

colors = ["r","y","g","b","r","g","r"]
sizes = [10,90,80,70,60,50,400]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no,c = colors,s = sizes,edgecolor = "g",linewidth = 2)
plt.show()
In [47]:
import matplotlib.pyplot as plt
day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]

colors = [10,49,30,29,56,20,30]#cmap property(this is use only numbers)
sizes = [10,90,80,70,60,50,400]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no,c = colors,s = sizes,cmap = 'BrBG')
plt.colorbar()
plt.show()
In [16]:
import matplotlib.pyplot as plt
day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]

#colors = ["r","y","g","b","r","g","r"]
colors = [10,49,30,29,56,20,30]#cmap property
sizes = [10,90,80,70,60,50,400]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no,c = colors,s = sizes,cmap = 'BrBG')
t = plt.colorbar()
t.set_label("ColorBar",fontsize = 15)#t is use only label,means colorbar
plt.show()
In [17]:
import matplotlib.pyplot as plt

day = [1,2,3,4,5,6,7]
no = [4,5,6,7,8,9,4]
no2 = [3,2,4,5,6,7,8]

colors = [10,49,30,29,56,20,30]
sizes = [10,90,80,70,60,50,400]

plt.title("Scatter plot",fontsize = 15)
plt.xlabel("Day",fontsize = 15)
plt.ylabel("No",fontsize = 15)

plt.scatter(day,no,c = colors,s = sizes,cmap = 'BrBG')#multiple plots use
plt.scatter(day,no2,color = 'r',s = sizes)

t = plt.colorbar()
t.set_label("ColorBar",fontsize = 15)
plt.show()

Histogram Plot¶

In [18]:
import matplotlib.pyplot as plt

x = []

plt.hist(x)
plt.show()
In [19]:
import matplotlib.pyplot as plt
import numpy as np
import random

x = np.random.randint(10,60,(50))
print(x)
[31 21 12 43 18 34 19 25 52 57 14 35 26 44 57 19 36 49 41 31 36 34 23 21
 13 48 15 10 47 49 46 30 39 23 14 38 31 29 48 15 50 25 57 16 46 53 30 30
 46 48]
In [20]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]#use comma

plt.hist(no)

plt.show()
In [48]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [49]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "y")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [50]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "y",edgecolor = 'b')

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [21]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",edgecolor = "r")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [54]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",bins = 5,edgecolor = "r")#bins means parts of graph i means bar of graph

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [55]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,"auto",(0,100),edgecolor = "r")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [24]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",edgecolor = "r",cumulative = -1)#cumulative is reverse the graph -1

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [25]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",edgecolor = "r",cumulative = 1)#grow the graph

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [56]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",edgecolor = "r",bottom = 10)#bottom is use the graph is start sequencial form

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [57]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",edgecolor = "r",align = "mid")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [59]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",edgecolor = "r",histtype = "step")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [27]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",edgecolor = "r",histtype = "stepfilled")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [61]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",edgecolor = "r",histtype = "barstacked")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [60]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",edgecolor = "r",histtype = "bar")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [30]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "k",edgecolor = "r",orientation = "horizontal")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [31]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "c",edgecolor = "r",orientation = "vertical")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [32]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "b",edgecolor = "r",rwidth = 0.8)

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [33]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "g",edgecolor = "r",log = True)#y-axis is change log form

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.show()
In [62]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "y",edgecolor = "r",label = "python")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

#plt.axvline(45,color = "r",label = "line")

plt.legend()#legend use only label
plt.show()
In [64]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "m",edgecolor = "k",label = "python")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.axvline(45,color = "r")

plt.legend()
#plt.grid()
plt.show()
In [65]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "m",edgecolor = "k",label = "python")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.axvline(45,color = "r",label = "line")

plt.legend()
#plt.grid()
plt.show()
In [66]:
no = [45,11,48,53,12,59,35,39,41,17,52,21,20,34,51,30,25,16,25,24,19,16,44,22,
37,10,57,39,29,42,29,41,26,18,13,48,49,39,33,39,44,48,54,19,46,41,20,21,
53,16]

l = [10,20,30,40,50,60]

plt.hist(no,color = "m",edgecolor = "k",label = "python")

plt.title("wscube")
plt.xlabel("python")
plt.ylabel("No.")

plt.axvline(45,color = "r",label = "line")

plt.legend()
plt.grid()
plt.show()

Pie Plot¶

In [36]:
import matplotlib.pyplot as plt

x = []

plt.pie(x)
plt.show()
In [67]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]

plt.pie(x)
plt.show()
In [37]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]

plt.pie(x,labels = y)
plt.show()
In [38]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]#alg se part show karne ke liye

plt.pie(x,labels = y,explode = ex)
plt.show()
In [39]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,colors = c,autopct = "%0.1f%%")#autopact use only show percentage
plt.show()
In [40]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,autopct = "%0.2f%%",shadow = True)
plt.show()
In [68]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,colors = c,autopct = "%0.1f%%",radius = 1.5)
plt.show()
In [71]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,autopct = "%0.1f%%",labeldistance = 1.3)#labeldistance is use only manage labels distance
plt.show()
In [72]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,colors = c,autopct = "%0.1f%%",startangle=90)#startangle means rotation
plt.show()
In [44]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,colors = c,autopct = "%0.1f%%",startangle=180)
plt.show()
In [45]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,colors = c,autopct = "%0.1f%%",startangle=0)
plt.show()
In [46]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,colors = c,autopct = "%0.1f%%",startangle=90,textprops = {"fontsize":15})#textprops use only fontsize
plt.show()
In [47]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,colors = c,autopct = "%0.1f%%",startangle=90,counterclock = True)#counterclock is true means no change in pie chart
plt.show()
In [48]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,colors = c,autopct = "%0.1f%%",startangle=0,counterclock = False)#false change the diagram
plt.show()
In [77]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,autopct = "%0.1f%%",startangle=90,counterclock = True,wedgeprops = {"linewidth":14})#wedgeprops means changes the border shadow(edges)

plt.title("Wscube Tech")
plt.legend(loc=4)
plt.show()
In [78]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,autopct = "%0.1f%%",startangle=90,counterclock = True,wedgeprops = {"linewidth":10})#wedgeprops means changes the border shadow(edges)

plt.title("Wscube Tech")
plt.legend(loc=4)
plt.show()
In [79]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,autopct = "%0.1f%%",startangle=90,counterclock = True,wedgeprops = {"linewidth":14,"width":2})#wedgeprops means changes the border shadow(edges)

plt.title("Wscube Tech")
plt.legend(loc=4)
plt.show()
In [87]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,autopct = "%0.1f%%",startangle=30,counterclock = True,wedgeprops = {"linewidth":14,"edgecolor":'m'})#wedgeprops means changes the border shadow(edges)

plt.title("Wscube Tech")
plt.legend(loc=4)
plt.show()
In [84]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,autopct = "%0.1f%%",startangle=90,counterclock = True,wedgeprops = {"linewidth":14,"edgecolor":'m'},center=(3,6))#wedgeprops means changes the border shadow(edges)

plt.title("Wscube Tech")
plt.legend(loc=4)
plt.show()
In [85]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,autopct = "%0.1f%%",startangle=90,counterclock = True,wedgeprops = {"linewidth":14,"edgecolor":'m'},rotatelabels=True)
plt.title("Wscube Tech")
plt.legend(loc=4)
plt.show()
In [86]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
y = ["c","c++","java","python"]
ex = [0.4,0.0,0.0,0.0]
c = ["r","b","g","y"]

plt.pie(x,labels = y,explode = ex,autopct = "%0.1f%%",startangle=90,counterclock = True,wedgeprops = {"linewidth":14,"edgecolor":'m'},rotatelabels=False)
plt.title("Wscube Tech")
plt.legend(loc=4)#loc change th elocation of y label
plt.show()
In [50]:
plt.pie([1])
plt.show()
In [89]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
x1 =[40,30,20,10]
y = ["c","c++","java","python"]

#c = ["r","b","g","y"]

plt.pie(x,labels = y,radius = 1.5)
plt.pie(x1,radius = 1)
#plt.pie([1],colors = "w")

plt.show()
In [90]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
x1 =[40,30,20,10]
y = ["c","c++","java","python"]

c = ["r","b","g","y"]

plt.pie(x,labels = y,radius = 1.5)
plt.pie(x1,radius = 1,colors = c)
#plt.pie([1],colors = "w")

plt.show()
In [88]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
x1 =[40,30,20,10]
y = ["c","c++","java","python"]

c = ["r","b","g","y"]

plt.pie(x,labels = y,radius = 1.5)
#plt.pie(x1,radius = 1,colors = c)
plt.pie([1],colors = "w")#w means white

plt.show()
In [52]:
import matplotlib.pyplot as plt

x = [10,20,30,40]
x1 =[40,30,20,10]
y = ["c","c++","java","python"]

c = ["r","b","g","y"]

plt.pie(x,labels = y,radius = 1.5)
cr = plt.Circle(xy=(0,0),radius=1,facecolor="w")
plt.gca().add_artist(cr)

plt.show()

Stem Plot¶

In [53]:
import matplotlib.pyplot as plt

x = []
y = []

plt.stem(x,y)
plt.show()
In [54]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y)

plt.show()
In [55]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="r+")#fmt means change format

plt.show()
In [56]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="r*")

plt.show()
In [57]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="ro")

plt.show()
In [58]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="r+",bottom=1)

plt.show()
In [59]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="r+",bottom=9)

plt.show()
In [60]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="r+",basefmt="g")

plt.show()
In [61]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="r+",label = "python")

plt.legend()
plt.show()
In [62]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="r+",use_line_collection = True)

plt.show()
C:\Users\abhio\AppData\Local\Temp\ipykernel_3744\446448563.py:6: MatplotlibDeprecationWarning: The 'use_line_collection' parameter of stem() was deprecated in Matplotlib 3.6 and will be removed two minor releases later. If any parameter follows 'use_line_collection', they should be passed as keyword, not positionally.
  plt.stem(x,y,linefmt=":",markerfmt="r+",use_line_collection = True)
In [63]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="r+",use_line_collection = False)

plt.show()
C:\Users\abhio\AppData\Local\Temp\ipykernel_3744\2568370099.py:6: MatplotlibDeprecationWarning: The 'use_line_collection' parameter of stem() was deprecated in Matplotlib 3.6 and will be removed two minor releases later. If any parameter follows 'use_line_collection', they should be passed as keyword, not positionally.
  plt.stem(x,y,linefmt=":",markerfmt="r+",use_line_collection = False)
In [64]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="r+",use_line_collection = True,orientation = "horizontal")

plt.show()
C:\Users\abhio\AppData\Local\Temp\ipykernel_3744\2972662392.py:6: MatplotlibDeprecationWarning: The 'use_line_collection' parameter of stem() was deprecated in Matplotlib 3.6 and will be removed two minor releases later. If any parameter follows 'use_line_collection', they should be passed as keyword, not positionally.
  plt.stem(x,y,linefmt=":",markerfmt="r+",use_line_collection = True,orientation = "horizontal")
In [65]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,3,4,5,6,4]

plt.stem(x,y,linefmt=":",markerfmt="r+",use_line_collection = True)

plt.show()
C:\Users\abhio\AppData\Local\Temp\ipykernel_3744\446448563.py:6: MatplotlibDeprecationWarning: The 'use_line_collection' parameter of stem() was deprecated in Matplotlib 3.6 and will be removed two minor releases later. If any parameter follows 'use_line_collection', they should be passed as keyword, not positionally.
  plt.stem(x,y,linefmt=":",markerfmt="r+",use_line_collection = True)

Box Plot/Whisker Plot¶

In [66]:
import matplotlib.pyplot as plt

x = []

plt.boxplot(x)

plt.show()
In [67]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70]

plt.boxplot(x)
plt.show()
In [91]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70]

plt.boxplot(x,notch = True)
plt.show()
In [68]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70]

plt.boxplot(x,vert = False)
plt.show()
In [69]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70]

plt.boxplot(x,widths = 0.8 )
plt.show()
In [70]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70]

plt.boxplot(x,labels = ["Python"])
plt.show()
In [71]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70]

plt.boxplot(x,labels = ["Python"],patch_artist = True)#fill the color
plt.show()
In [72]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70]

plt.boxplot(x,labels = ["Python"],patch_artist = False,showmeans = True)
plt.show()
In [73]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70,120]#outlier 120 bcoz is is long gap provide

plt.boxplot(x,labels = ["Python"],patch_artist = False,showmeans = True)
plt.show()
In [93]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70,120]

plt.boxplot(x,labels = ["Python"],patch_artist = False,showmeans = True,whis =3.5)
plt.show()
In [96]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70]

plt.boxplot(x,labels = ["Python"],patch_artist = False,showmeans = True,sym = "g+")
plt.show()
In [75]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70,120]

plt.boxplot(x,labels = ["Python"],patch_artist = False,showmeans = True,sym = "g+")
plt.show()
In [76]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70,120]

plt.boxplot(x,labels = ["Python"],patch_artist = False,showmeans = True,sym = "")
plt.show()
In [97]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70,120]

plt.boxplot(x,labels = ["Python"],patch_artist = False,showmeans = True,boxprops = dict(color="r"),capprops = dict(color = "y"))
plt.show()
In [78]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70,120]

plt.boxplot(x,labels = ["Python"],patch_artist = False,showmeans = True,boxprops = dict(color="r"),capprops=dict(color="m"))
plt.show()
In [79]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70,120]

plt.boxplot(x,labels = ["Python"],patch_artist = False,showmeans = True,boxprops = dict(color="r"),whiskerprops=dict(color="g"))
plt.show()
In [80]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70,120]

plt.boxplot(x,labels = ["Python"],patch_artist = False,showmeans = True,boxprops = dict(color="r"),whiskerprops=dict(color="g"),flierprops=dict(markeredgecolor="y"))
plt.show()
In [81]:
import matplotlib.pyplot as plt

x = [10,20,30,40,50,60,70,120]
x1 = [10,20,30,40,50,60,90,80,150]

y = [x,x1]
plt.boxplot(y,labels = ["python","c++"] ,patch_artist = False,showmeans = True,boxprops = dict(color="r"),whiskerprops=dict(color="g"),flierprops=dict(markeredgecolor="y"))
plt.show()

Stack Plot/Area Plot¶

In [82]:
import matplotlib.pyplot as plt

x = []
y = []

plt.stackplot(x,y)
plt.show()
In [83]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]

plt.stackplot(x,area)
plt.show()
In [84]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

plt.stackplot(x,area,area1,area2)
plt.show()
In [2]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

l = ["area","area1","area2"]
plt.stackplot(x,area,area1,area2,labels = l)

plt.legend()
plt.show()
In [3]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

l = ["area","area1","area2"]
plt.stackplot(x,area,area1,area2,labels = l,colors = ["r","g","m"])

plt.legend()
plt.show()
In [4]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

l = ["area","area1","area2"]
plt.stackplot(x,area,area1,area2,labels = l,colors = ["r","g","m"])

plt.legend(loc=2)
plt.show()
In [7]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

l = ["area","area1","area2"]
plt.stackplot(x,area,area1,area2,labels = l,colors = ["r","g","m"],baseline="zero")#zero not effect on graph
plt.legend(loc=2)
plt.show()
In [8]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

l = ["area","area1","area2"]
plt.stackplot(x,area,area1,area2,labels = l,colors = ["r","g","m"],baseline="wiggle")#zero not effect on graph
plt.legend(loc=2)
plt.show()
In [6]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

l = ["area","area1","area2"]
plt.stackplot(x,area,area1,area2,labels = l,colors = ["r","g","m"],baseline="sym")#baseline means change the base line
#sym provide effect in graph
plt.legend(loc=2)
plt.show()
In [87]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

l = ["area","area1","area2"]
plt.stackplot(x,area,area1,area2,labels = l,colors = ["r","g","m"],baseline="zero")

plt.legend()
plt.show()
In [88]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

l = ["area","area1","area2"]
plt.stackplot(x,area,area1,area2,labels = l,colors = ["r","g","m"])

plt.legend()
plt.show()
In [89]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

l = ["area","area1","area2"]
plt.stackplot(x,area,area1,area2,labels = l,colors = ["r","g","m"])

plt.title("python")
plt.xlabel("x-axis")
plt.ylabel("y-axis")

plt.legend()
plt.show()
In [10]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
area = [6,2,3,9,5]
area1 = [6,2,3,9,5]
area2 = [1,2,5,9,8]

l = ["area","area1","area2"]
plt.stackplot(x,area,area1,area2,labels = l,colors = ["r","g","m"])

plt.grid()
plt.legend()
plt.show()

Step Plot¶

In [91]:
import matplotlib.pyplot as plt

x = []
y = []

plt.step(x,y)
plt.show()
In [11]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [1,2,3,4,5]

plt.step(x,y)
plt.show()
In [12]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [1,2,3,4,5]

plt.step(x,y)
plt.grid()
plt.show()
In [14]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [1,2,6,8,5]

plt.title("python",fontsize = 25)
plt.xlabel("x - axis ")
plt.ylabel("y - axis ")

plt.step(x,y)
plt.grid()
plt.show()
In [16]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [1,2,6,8,5]

plt.title("python")
plt.xlabel("x - axis ")
plt.ylabel("y - axis ")

plt.grid()
plt.step(x,y,color = "r",marker="o")

plt.show()
In [17]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [1,2,6,8,5]

plt.title("python")
plt.xlabel("x - axis ")
plt.ylabel("y - axis ")

plt.grid()
plt.step(x,y,color = "r",marker="o",ms=20)#ms means marker size

plt.show()
In [18]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [1,2,6,8,5]

plt.title("python")
plt.xlabel("x - axis ")
plt.ylabel("y - axis ")

plt.grid()
plt.step(x,y,color = "r",marker="o",ms = 10,mfc = "g")#mfc means marker face color

plt.show()
In [19]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [1,2,6,8,5]

plt.title("python")
plt.xlabel("x - axis ")
plt.ylabel("y - axis ")

plt.grid()
plt.step(x,y,color = "r",marker="o",ms = 10,mfc = "g",label="python")

plt.legend(loc=2)#label location change
plt.show()

Fill_Between Plot¶

In [ ]:
import matplotlib.pyplot as plt

x = []
y = []

plt.plot(x,y)
plt.fill_between()
plt.show()
In [20]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [1,2,3,4,5]

plt.plot(x,y)

plt.show()
In [94]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [1,2,3,4,5]

plt.plot(x,y,color="r")

plt.show()
In [22]:
import matplotlib.pyplot as plt

x =np.array([1,2,3,4,5])
y =np.array([1,2,3,4,5])

plt.plot(x,y,color="r")

plt.title("python")
plt.xlabel("x-axis")
plt.ylabel("y-axis")

plt.show()
In [23]:
import matplotlib.pyplot as plt

x =np.array([1,2,3,4,5])
y =np.array([1,2,3,4,5])

plt.plot(x,y,color="r")

plt.fill_between(x,y)

plt.title("python")
plt.xlabel("x-axis")
plt.ylabel("y-axis")

plt.show()
In [24]:
import matplotlib.pyplot as plt

x =np.array([1,2,3,4,5])
y =np.array([1,2,3,4,5])

plt.plot(x,y,color="r")

plt.fill_between(x=[2,4],y1=2,y2=4)

plt.title("python")
plt.xlabel("x-axis")
plt.ylabel("y-axis")

plt.show()
In [26]:
import matplotlib.pyplot as plt

x =np.array([1,2,3,4,5])
y =np.array([1,2,3,4,5])

plt.plot(x,y,color="r")

plt.fill_between(x,y,color="m")

plt.title("python")
plt.xlabel("x-axis")
plt.ylabel("y-axis")

plt.show()
In [27]:
import matplotlib.pyplot as plt
import numpy as np

x =np.array([1,2,3,4,5])
y =np.array([1,2,3,4,5])

plt.plot(x,y,color="r")

plt.fill_between(x,y,color="g",where=(x>=2) & (x<=4))

plt.title("python")
plt.xlabel("x-axis")
plt.ylabel("y-axis")

plt.show()
In [95]:
import matplotlib.pyplot as plt
import numpy as np

x =np.array([1,2,3,4,5])
y =np.array([1,2,3,4,5])

plt.plot(x,y,color="r")

plt.fill_between(x,y,color="g",where=(x>=2) & (x<=4),alpha=0.3)

plt.title("python")
plt.xlabel("x-axis")
plt.ylabel("y-axis")

plt.show()

SubPlot¶

In [ ]:
import matplotlib.pyplot as plt

x = []
y = []

plt.subplot(nrows,ncols,index)

plt.plot(x,y)
plt.show()
In [28]:
import matplotlib.pyplot as plt

x = [1,2,3,4]
y = [1,2,3,4]

plt.plot(x,y,color = 'r')

plt.show()
In [32]:
import matplotlib.pyplot as plt

x = [1,2,3,4]
y = [1,2,3,4]

plt.plot(x,y,color = 'r')
plt.pie([1],colors='r')

plt.show()
In [33]:
import matplotlib.pyplot as plt

x = [1,2,3,4]
y = [1,2,3,4]

plt.plot(x,y,color = 'r')
plt.pie([1],colors='r')

x1 = [10,20,30,40]
plt.pie(x)

plt.show()
In [34]:
import matplotlib.pyplot as plt

x = [1,2,3,4]
y = [1,2,3,4]

plt.plot(x,y,color = 'r')
plt.pie([1],colors='r')

x1 = [10,20,30,40]
plt.pie(x)

x2 = ["a","s","d","f"]
y2 = [10,20,30,40]
plt.bar(x2,y2)


plt.show()
In [35]:
import matplotlib.pyplot as plt

x = [1,2,3,4]
y = [1,2,3,4]

#plt.plot(x,y,color = 'r')
#plt.pie([1],colors='r')

#x1 = [10,20,30,40]
#plt.pie(x)

x2 = ["a","s","d","f"]
y2 = [10,20,30,40]
plt.bar(x2,y2)


plt.show()
In [37]:
import matplotlib.pyplot as plt

x = [1,2,3,4]
y = [1,2,3,4]

plt.subplot(2,2,1)
plt.plot(x,y,color = 'r')

plt.subplot(2,2,2)
plt.pie([1],colors='r')

x1 = [10,20,30,40]
plt.subplot(2,2,3)
plt.pie(x)

x2 = ["a","s","d","f"]
y2 = [10,20,30,40]
plt.subplot(2,2,4)
plt.bar(x2,y2)


plt.show()

Savefig¶

In [ ]:
import matplotlib.pyplot as plt

x = []
y = []

plt.plot(x,y)
plt.savefig(fname)

plt.show()
In [39]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [2,4,6,8,10]

plt.plot(x,y)

plt.show()
In [41]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [2,4,7,3,10]

plt.plot(x,y,color='r')

plt.show()
In [42]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [2,4,7,3,10]

plt.plot(x,y,color='r')
plt.savefig("line")

plt.show()
In [44]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [2,4,7,3,10]

plt.plot(x,y,color='r')
plt.savefig("line",dpi=2000)#dpi means dot per mintes

plt.show()
In [45]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [2,4,7,3,10]

plt.plot(x,y,color='r')
plt.savefig("line",dpi=2000,facecolor = 'g')#dpi means dot per mintes

plt.show()

Axis Plots¶

  • xticks(),yticks(),xlim(),ylim(),axis()
In [14]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,4]

plt.plot(x,y)
plt.show()
In [2]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,4]

plt.plot(x,y)
plt.xticks(x)#xticks means data is convert non decimal value

plt.show()
In [5]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,4]

plt.plot(x,y)
plt.yticks(y)

plt.show()
In [4]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,4]

plt.plot(x,y)
plt.xticks(x)
plt.yticks(y)

plt.show()
In [6]:
import matplotlib.pyplot as plt

x = [1,2,4,5]
y = [3,5,2,4]

plt.plot(x,y)
plt.xticks(x,labels=["python","c","c++","java"])
plt.yticks(y)

plt.show()
In [11]:
import matplotlib.pyplot as plt

x = [1,2,4,5]
y = [3,5,2,4]

plt.plot(x,y)
plt.xlim(0,10)

plt.show()
In [8]:
import matplotlib.pyplot as plt

x = [1,2,4,5]
y = [3,5,2,4]

plt.plot(x,y)

plt.xlim(0,10)#range of x-axis
plt.ylim(0,10)

plt.show()
In [12]:
import matplotlib.pyplot as plt

x = [1,2,4,5]
y = [3,5,2,4]

plt.plot(x,y)

plt.axis([0,10,0,7])#axis means your data range x(0,10) y(0,7)

plt.show()

Text Plots¶

  • text,annotate,xlabel,ylabel,title
In [15]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.show()
In [17]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)

plt.show()
In [19]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)
plt.xlabel("Days",fontsize=15)

plt.show()
In [22]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)
plt.xlabel("Days",fontsize=15)
plt.ylabel("Python",fontsize=15)

plt.xticks(x)#remove decimal value

plt.show()
In [23]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)
plt.xlabel("Days",fontsize=15)
plt.ylabel("Python",fontsize=15)

plt.text(2,5,"python")

plt.show()
In [25]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)
plt.xlabel("Days",fontsize=15)
plt.ylabel("Python",fontsize=15)

plt.text(2,5,"CHANDA",fontsize=15)

plt.show()
In [26]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)
plt.xlabel("Days",fontsize=15)
plt.ylabel("Python",fontsize=15)

plt.text(2,5,"CHANDA",fontsize=15,style="italic")

plt.show()
In [27]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)
plt.xlabel("Days",fontsize=15)
plt.ylabel("Python",fontsize=15)

plt.text(2,5,"CHANDA",fontsize=15,style="italic",bbox={"facecolor":"red"})

plt.show()
In [30]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)
plt.xlabel("Days",fontsize=15)
plt.ylabel("Python",fontsize=15)

plt.text(2,5,"CHANDA",fontsize=15,style="italic",bbox={"facecolor":"red"})
plt.annotate("python",xy=(2,1),xytext=(4,4),arrowprops=dict(facecolor="black",shrink=100))

plt.show()
In [37]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)
plt.xlabel("Days",fontsize=15)
plt.ylabel("Python",fontsize=15)

#plt.text(2,5,"CHANDA",fontsize=15,style="italic",bbox={"facecolor":"red"})
#plt.annotate("python",xy=(2,1),xytext=(4,4),arrowprops=dict(facecolor="black",shrink=100))

plt.legend(["up"],loc=1)#legend define only 10 location numbers
plt.show()
In [43]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)
plt.xlabel("Days",fontsize=15)
plt.ylabel("Python",fontsize=15)

#plt.text(2,5,"CHANDA",fontsize=15,style="italic",bbox={"facecolor":"red"})
#plt.annotate("python",xy=(2,1),xytext=(4,4),arrowprops=dict(facecolor="black",shrink=100))

plt.legend(["up"],loc=1,facecolor="r",edgecolor="y",framealpha=0.5,shadow=True)
plt.show()
In [44]:
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [3,1,5,2,6]

plt.plot(x,y)

plt.title("WsCube",fontsize=20)
plt.xlabel("Days",fontsize=15)
plt.ylabel("Python",fontsize=15)

plt.legend(["up"],loc=1,facecolor="r",edgecolor="y",framealpha=0.5,shadow=True)
plt.show()
In [ ]: